package util

import (
	"os"
	"path/filepath"
)

type Resource struct {
	root string
}

var Public = Resource{
	root: filepath.Dir(os.Args[0]),
}

func (o *Resource) Root(dir string) {
	if filepath.IsAbs(dir) {
		o.root = dir
	} else {
		o.root = o.Abs(dir)
	}
}

func (o *Resource) Abs(dirs ...string) string {
	public := filepath.Join(dirs...)
	return filepath.Join(o.root, public)
}
